package lhy.orm.model;

import lhy.autoparts.SharedConstant;
import lhy.utils.ReflectUtils;

import java.io.Serializable;

public class FieldData implements Serializable {

    private String fieldName;
    private String fieldComment;
    private String typeClassName;
    private String typeClassShortName;
    private boolean isIdentity;
    private boolean isAutoIncrement;
    private boolean isNullable;
    private boolean hasForeignKey;

    public FieldData() {
    }

    public FieldData(String fieldName, String fieldComment, String typeClassName, String typeClassShortName, boolean isIdentity, boolean isAutoIncrement, boolean isNullable, boolean hasForeignKey) {
        this.fieldName = fieldName;
        this.fieldComment = fieldComment;
        this.typeClassName = typeClassName;
        this.typeClassShortName = typeClassShortName;
        this.isIdentity = isIdentity;
        this.isAutoIncrement = isAutoIncrement;
        this.isNullable = isNullable;
        this.hasForeignKey = hasForeignKey;
    }
    public boolean isDate(){
        return this.typeClassShortName.equals("Date");
    }
    public boolean isTypeClassGenerateId(){
        return SharedConstant.AUTO_GENERATE_ID_ENTITY_PREFIX.keySet().contains(ReflectUtils.loadClassByName(typeClassName));
    }
    public boolean isMoney(){
        return "double".equalsIgnoreCase(this.typeClassShortName);
    }
    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public String getFieldComment() {
        return fieldComment;
    }

    public void setFieldComment(String fieldComment) {
        this.fieldComment = fieldComment;
    }

    public String getTypeClassName() {
        return typeClassName;
    }

    public void setTypeClassName(String typeClassName) {
        this.typeClassName = typeClassName;
    }

    public String getTypeClassShortName() {
        return typeClassShortName;
    }

    public void setTypeClassShortName(String typeClassShortName) {
        this.typeClassShortName = typeClassShortName;
    }

    public boolean getIsIdentity() {
        return isIdentity;
    }

    public void setIdentity(boolean identity) {
        isIdentity = identity;
    }

    public boolean getIsAutoIncrement() {
        return isAutoIncrement;
    }

    public void setAutoIncrement(boolean autoIncrement) {
        isAutoIncrement = autoIncrement;
    }

    public boolean getIsNullable() {
        return isNullable;
    }

    public void setNullable(boolean nullable) {
        isNullable = nullable;
    }

    public boolean getHasForeignKey() {
        return hasForeignKey;
    }

    public void setHasForeignKey(boolean hasForeignKey) {
        this.hasForeignKey = hasForeignKey;
    }
}
